public class Leet396 {
    public int maxRotateFunction(int[] nums) {
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < nums.length; i++) {
            int temp = 0;
            for (int j = i+1; j < i+nums.length; j++) {
                temp+=(j-i)*nums[j%nums.length];
            }
            max = Math.max(max,temp);
        }
        return max;
    }
}
